module common.sprite;

import std.stream;
import mirdefine;

/******************************************************************************************************************

    Actor Sprite Frame Define

*******************************************************************************************************************/

//~~~ Hero¿Í ¸ó½ºÅÍ, NPC¸¦ À§ÇÑ ÇÁ·¹ÀÓÁ¤ÀÇ. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct SpriteFrameInfo
{
    ushort      FirstFrame;                 // µ¿ÀÛÀÇ ½ÃÀÛ ÇÁ·¹ÀÓ.
    ushort      FrameCount;                 // µ¿ÀÛÀÇ ÇÁ·¹ÀÓ°¹¼ö.
    ushort      FrameDelay;                 // µ¿ÀÛÀÇ Áö¿¬½Ã°£.
}
alias SpriteFrameInfo* PSpriteFrameInfo;


/******************************************************************************************************************

    Effect Sprite Frame Define

*******************************************************************************************************************/

//~~~ ¸¶¹ýÀ» À§ÇÑ ÇÁ·¹ÀÓÁ¤ÀÇ. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct SpriteEffectInfo
{
    uint        dwFstFrm;
    uint        dwEndFrm;
    ushort      wDelay;
    ushort      wImgIdx;
    ushort      wEffectIdx;
    ubyte       bLightRadius[2];                // ±¤¿ø ³Êºñ.
    ubyte       bLightColor[2][3];             // ±¤¿ø »ö.
    ubyte       bMagicColor[3];                // ¸¶¹ý »ö.
    ubyte       bBlendType;
    ubyte       bOpa;
    ubyte       bSwingCnt;
}
alias SpriteEffectInfo* PSpriteEffectInfo;


public class Sprite
{
    public SpriteEffectInfo     m_stEffectSpr[_MAX_EFFECT];         // ¸¶¹ýÀÇ ½ÃÀü¹× °Ë¹ýÈ¿°ú.
    public SpriteEffectInfo     m_stMagicSpr[_MAX_MAGIC];           // ¸¶¹ýÈ¿°ú.
    public SpriteEffectInfo     m_stExplosionSpr[_MAX_EXPLOSION];   // ¸¶¹ýÆø¹ßÈ¿°ú.

    public SpriteEffectInfo     m_stMonEffectSpr[_MAX_EFFECT];          // ¸¶¹ýÀÇ ½ÃÀü¹× °Ë¹ýÈ¿°ú.
    public SpriteEffectInfo     m_stMonMagicSpr[_MAX_MAGIC];            // ¸¶¹ýÈ¿°ú.
    public SpriteEffectInfo     m_stMonExplosionSpr[_MAX_EXPLOSION];    // ¸¶¹ýÆø¹ßÈ¿°ú.


    public SpriteFrameInfo      m_stHeroSpr[_MAX_HERO_MTN];         // HeroÀÇ µ¿ÀÛÇÁ·¹ÀÓ Á¤ÀÇ.
    public SpriteFrameInfo      m_stMonSpr [_MAX_MON_MTN];          // MonsterÀÇ µ¿ÀÛÇÁ·¹ÀÓ Á¤ÀÇ.
    public SpriteFrameInfo      m_stNPCSpr [_MAX_MON_MTN];          // MonsterÀÇ µ¿ÀÛÇÁ·¹ÀÓ Á¤ÀÇ.

    public ubyte                m_bWOrder[_MAX_HERO_REALFRAME]; 


    public this()
    {
        InitSpriteInfo();
    }
        
    public ~this()
    {
        DeleteSpriteInfo();
    }

    public void InitSpriteInfo()
    {
        /*ZeroMemory(m_stHeroSpr,     sizeof(SPRFRMDEF)*_MAX_HERO_MTN);
        ZeroMemory(m_stMonSpr,      sizeof(SPRFRMDEF)*_MAX_MON_MTN);
        ZeroMemory(m_stNPCSpr,      sizeof(SPRFRMDEF)*_MAX_NPC_MTN);

        ZeroMemory(m_stEffectSpr,   sizeof(EFFECTSPRINFO)*_MAX_EFFECT);
        ZeroMemory(m_stMagicSpr,    sizeof(EFFECTSPRINFO)*_MAX_MAGIC);
        ZeroMemory(m_stExplosionSpr,sizeof(EFFECTSPRINFO)*_MAX_EXPLOSION);*/
    }
        
    public void DeleteSpriteInfo()
    {
        InitSpriteInfo();
    }

    public void SetInfo()
    {
        SetWeaponOrder("weapon.ord");

        //~~~ Hero ½ºÇÁ¶óÀÌÆ® ¼³Á¤. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetSprDfn(&m_stHeroSpr[0],     0,  4, 200);         // Motion.Stand        
        SetSprDfn(&m_stHeroSpr[1],    80,  6, 100);         // Motion.ArrowAttack  
        SetSprDfn(&m_stHeroSpr[2],   160,  5,  80);         // Motion.Spell1       
        SetSprDfn(&m_stHeroSpr[3],   240,  5,  80);         // Motion.Spell2       
        SetSprDfn(&m_stHeroSpr[4],   320,  1, 100);         // Motion.Hold     
        SetSprDfn(&m_stHeroSpr[5],   400,  1, 100);         // Motion.PushBack 
        SetSprDfn(&m_stHeroSpr[6],   480,  1, 100);         // Motion.PushBackFly  
        SetSprDfn(&m_stHeroSpr[7],   560,  3, 200);         // Motion.AttackMode   
        SetSprDfn(&m_stHeroSpr[8],   640,  2, 300);         // Motion.Cut          
        SetSprDfn(&m_stHeroSpr[9],   720,  6,  85);         // Motion.OneVSwing
        SetSprDfn(&m_stHeroSpr[10],  800,  6,  85);         // Motion.TwoVSwing    
        SetSprDfn(&m_stHeroSpr[11],  880,  6,  85);         // Motion.OneHSwing    
        SetSprDfn(&m_stHeroSpr[12],  960,  6,  85);         // Motion.TwoHSwing    
        SetSprDfn(&m_stHeroSpr[13], 1040,  6,  85);         // Motion.SpearVSwing  
        SetSprDfn(&m_stHeroSpr[14], 1120,  6,  85);         // Motion.SpearHSwing  
        SetSprDfn(&m_stHeroSpr[15], 1200,  3, 100);         // Motion.Hitted       
        SetSprDfn(&m_stHeroSpr[16], 1280, 10,  70);         // Motion.WheelWind    
        SetSprDfn(&m_stHeroSpr[17], 1360, 10,  90);         // Motion.RandSwing    
        SetSprDfn(&m_stHeroSpr[18], 1440, 10, 100);         // Motion.BackDropKick
        SetSprDfn(&m_stHeroSpr[19], 1520, 10, 120);         // Motion.Die          
        SetSprDfn(&m_stHeroSpr[20], 1600, 10, 100);         // Motion.SpecialDie   
        SetSprDfn(&m_stHeroSpr[21], 1680,  6,  90);         // Motion.Walk     
        SetSprDfn(&m_stHeroSpr[22], 1760,  6, 120);         // Motion.Run          
        SetSprDfn(&m_stHeroSpr[23], 1840,  6, 100);         // Motion.Rush      
        SetSprDfn(&m_stHeroSpr[24], 1920, 10, 100);         // Motion.Roll     
        SetSprDfn(&m_stHeroSpr[25], 2000,  4, 180);         // Motion.FishStand    
        SetSprDfn(&m_stHeroSpr[26], 2080,  3, 180);         // Motion.FishHand 
        SetSprDfn(&m_stHeroSpr[27], 2160,  8, 180);         // Motion.FishThrow    
        SetSprDfn(&m_stHeroSpr[28], 2240,  8, 180);         // Motion.FishPull 
        SetSprDfn(&m_stHeroSpr[29], 2320,  4, 200);         // Motion.HorseStand   
        SetSprDfn(&m_stHeroSpr[30], 2400,  6, 100);         // Motion.HorseWalk    
        SetSprDfn(&m_stHeroSpr[31], 2480,  6, 100);         // Motion.HorseRun 
        SetSprDfn(&m_stHeroSpr[32], 2560,  3, 100);         // Motion.HorseHit 

        //~~~ Monster ½ºÇÁ¶óÀÌÆ® ¼³Á¤. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetSprDfn(&m_stMonSpr[0],     0,  4, 300);          // MonsterMotion.Stand
        SetSprDfn(&m_stMonSpr[1],    80,  6, 130);          // MonsterMotion.Walk
        SetSprDfn(&m_stMonSpr[2],   160,  6, 120);          // MonsterMotion.AttackA
        SetSprDfn(&m_stMonSpr[3],   240,  2, 300);          // MonsterMotion.Hitted
        SetSprDfn(&m_stMonSpr[4],   320, 10, 150);          // MonsterMotion.Die
        SetSprDfn(&m_stMonSpr[5],   400,  6, 150);          // MonsterMotion.AttackB
        SetSprDfn(&m_stMonSpr[6],   480, 10, 150);          // MonsterMotion.SpellA
        SetSprDfn(&m_stMonSpr[7],   560, 10, 150);          // MonsterMotion.SpellB
        SetSprDfn(&m_stMonSpr[8],   640,  6, 150);          // MonsterMotion.Appear

        //~~~ NPC ½ºÇÁ¶óÀÌÆ® ¼³Á¤. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetSprDfn(&m_stNPCSpr[0],     0,  4, 300);          // NpcMotion.Stand
        SetSprDfn(&m_stNPCSpr[1],    30, 10, 300);          // NpcMotion.Act1
        SetSprDfn(&m_stNPCSpr[2],    60,  6, 300);          // NpcMotion.Act2

        //~~~ Effect Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetEffectInfo(&m_stEffectSpr[0],   230,  236, 100, _IMAGE_MAGIC,       _SKILL_BANWOL, 3, 4, 100, 100, 100, 100, 100, 170);  // ¹Ý¿ù°ø°Ý 12½Ã.
        SetEffectInfo(&m_stEffectSpr[1],    60,   70, 100, _IMAGE_MAGIC,    _SKILL_AMYOUNSUL, 3, 4, 100, 100, 100, 100, 160, 100, 255, 255, 255, Blend.Normal);    // ¾Ï¿¬¼ú ½ÃÀü.
        SetEffectInfo(&m_stEffectSpr[2],    90,   98, 100, _IMAGE_MAGIC,     _SKILL_FIREWIND, 3, 4, 100, 100, 100, 100, 140, 180);  // È­¿°Ç³.
        SetEffectInfo(&m_stEffectSpr[3],  1820, 1828, 100, _IMAGE_MAGIC,         _SKILL_FIRE, 3, 4, 100, 100, 100, 100, 140, 180);  // ¿°»çÀå ½ÃÀü.
        SetEffectInfo(&m_stEffectSpr[4],     0,    9, 100, _IMAGE_MAGIC,      _SKILL_TAMMING, 3, 4, 100, 100, 100, 170, 100, 100);  // ·ÚÈ¥°Ý½ÃÀü.
        SetEffectInfo(&m_stEffectSpr[5],   110,  129, 100, _IMAGE_MAGIC,    _SKILL_SPACEMOVE, 3, 4, 100, 100, 100, 170, 100, 100);  // ¾Æ°øÇà¹ý.
        SetEffectInfo(&m_stEffectSpr[6],   130,  140, 100, _IMAGE_MAGIC,   _SKILL_KILLUNDEAD, 3, 4, 100, 100, 100, 170, 100, 100);  // »çÀÚÀ±È¸½ÃÀü.
        SetEffectInfo(&m_stEffectSpr[7],  1820, 1828, 100, _IMAGE_MAGIC,     _SKILL_FIREBALL, 3, 4, 100, 100, 100, 100, 140, 180);  // È­¿°Àå.
        SetEffectInfo(&m_stEffectSpr[8],   600,  610, 100, _IMAGE_MAGIC,     _SKILL_HEALLING, 3, 4, 100, 100, 100, 140, 100, 120);  // È¸º¹¼ú.
        SetEffectInfo(&m_stEffectSpr[9],   630,  640, 100, _IMAGE_MAGIC,   _SKILL_HOLYSHIELD, 3, 4, 100, 100, 100, 170, 100, 100);  // °á°è.
        SetEffectInfo(&m_stEffectSpr[10],  660,  670, 100, _IMAGE_MAGIC,  _SKILL_BIGHEALLING, 3, 4, 100, 100, 100, 140, 100, 120);  // ´ëÈ¸º¹.
        //  SetEffectInfo(&m_stEffectSpr[11],  690,  704, 100, _IMAGE_MAGIC,  _SKILL_LIGHTFLOWER, 3, 4, 100, 100, 100, 170, 100, 100);  // ·Ú¼³È­.
        SetEffectInfo(&m_stEffectSpr[11],  690,  704, 100, _IMAGE_MAGIC,  _SKILL_LIGHTFLOWER, 3, 4, 150, 100,  50, 150, 100,  50);  // ·Ú¼³È­.  
        SetEffectInfo(&m_stEffectSpr[12], 1970, 1978,  80, _IMAGE_MAGIC, _SKILL_SHOOTLIGHTEN, 3, 4, 100, 100, 100, 170, 100, 100);  // ·ÚÀÎÀå.
        SetEffectInfo(&m_stEffectSpr[13],  740,  750, 100, _IMAGE_MAGIC,    _SKILL_SKELLETON, 3, 4, 100, 100, 100, 120, 100, 120);  // ¹é°ñ¼ÒÈ¯¼ú.
        SetEffectInfo(&m_stEffectSpr[14],  770,  780, 100, _IMAGE_MAGIC,     _SKILL_SNOWWIND, 3, 4, 100, 100, 100, 170, 100, 100);  // ºù¼³Ç³.
        SetEffectInfo(&m_stEffectSpr[15],  870,  890, 100, _IMAGE_MAGIC,       _SKILL_SHOWHP, 3, 4, 100, 100, 100, 100, 100, 170);  // Å½±âÆÄ¿¬.
        SetEffectInfo(&m_stEffectSpr[16],  910,  920, 100, _IMAGE_MAGIC,    _SKILL_EARTHFIRE, 3, 4, 100, 100, 100, 100, 140, 180);  // Áö¿°¼ú.
        SetEffectInfo(&m_stEffectSpr[17],  940,  950, 100, _IMAGE_MAGIC,     _SKILL_FIREBOOM, 3, 4, 100, 100, 100, 100, 140, 180);  // Æø¿­ÆÄ.
        SetEffectInfo(&m_stEffectSpr[18], 1560, 1569, 100, _IMAGE_MAGIC,    _SKILL_FIREBALL2, 3, 4, 100, 100, 100, 100, 140, 180);  // ±Ý°­È­¿°Àå.
        SetEffectInfo(&m_stEffectSpr[19],  320,  326, 100, _IMAGE_MAGIC,        _SKILL_ERGUM, 3, 4, 100, 100, 100, 100, 100, 170);  // ¾î°Ë¼ú.
        SetEffectInfo(&m_stEffectSpr[20], 1350, 1356, 100, _IMAGE_MAGIC,         _SKILL_YEDO, 3, 4, 100, 100, 100, 100, 100, 170);  // ¿¹µµ°Ë¹ý.
        SetEffectInfo(&m_stEffectSpr[21], 1470, 1476, 100, _IMAGE_MAGIC,    _SKILL_FIRESWORD, 3, 4, 100, 100, 100, 100, 140, 180);  // ¿°È­°á.
        SetEffectInfo(&m_stEffectSpr[22], 1430, 1445, 100, _IMAGE_MAGIC,   _SKILL_LIGHTENING, 3, 4, 100, 100, 100, 170, 100, 100);  // °­°Ý.
        SetEffectInfo(&m_stEffectSpr[23],  810,  820, 100, _IMAGE_MAGIC,        _SKILL_CLOAK, 3, 4, 150, 150, 150, 200, 150, 180);  // Àº½Å.
        SetEffectInfo(&m_stEffectSpr[24], 2080, 2086, 100, _IMAGE_MAGIC, _SKILL_HANGMAJINBUB, 3, 4, 150, 100,  50, 200, 150, 100);  // Ç×¸¶Áø¹ý.
        SetEffectInfo(&m_stEffectSpr[25], 2080, 2086, 100, _IMAGE_MAGIC,    _SKILL_DEJIWONHO, 3, 4, 150, 180, 200, 180, 200, 220);  // ´ëÁö¿øÈ£.
        SetEffectInfo(&m_stEffectSpr[26], 2080, 2086, 100, _IMAGE_MAGIC,    _SKILL_FIRECHARM, 3, 4, 100, 150, 200, 150, 200, 250);  // Æø»ì°è.
        SetEffectInfo(&m_stEffectSpr[27], 2080, 2086, 100, _IMAGE_MAGIC,     _SKILL_BIGCLOAK, 3, 4, 150, 150, 150, 200, 150, 180);  // ´ëÀº½Å.
        SetEffectInfo(&m_stEffectSpr[28], 2180, 2190, 100, _IMAGE_MAGIC,     _SKILL_JUMPSHOT, 3, 4, 150, 150, 150, 200, 150, 180);  // Á¡ÇÁ¼¦.
        SetEffectInfo(&m_stEffectSpr[29], 2270, 2280, 100, _IMAGE_MAGIC,    _SKILL_RANDSWING, 3, 4, 150, 150, 150, 200, 150, 180);  // ·£´ý½ºÀ®.
        SetEffectInfo(&m_stEffectSpr[30], 2080, 2086, 100, _IMAGE_MAGIC,        _SKILL_SINSU, 3, 4, 150, 150, 150, 200, 150, 180, 255, 255, 255, Blend.Normal, 255);   // ½Å¼ö¼ÒÈ¯.

        SetEffectInfo(&m_stEffectSpr[31], 1680, 1686, 100, _IMAGE_MONMAGIC, _MONMAGIC_NUMAGUMGI, 3, 4, 150, 150, 150, 200, 150, 180, 255, 255, 255, Blend.Normal, 255);// ´©¸¶¿Õ °Ë±â.
        SetEffectInfo(&m_stEffectSpr[32], 830, 839, 100, _IMAGE_MAGIC, _SKILL_SHIELD, 3, 4, 100, 100, 100, 170, 100, 100);          // ÁÖ¼úÀÇ¸·.
        //~~~ Monster Effect Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        //~~~ Magic Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetEffectInfo(&m_stMagicSpr[0],    70,   88, 100, _IMAGE_MAGIC,    _SKILL_AMYOUNSUL, 3, 4, 190, 220, 190, 190, 240, 190, 255, 255, 255, Blend.Normal); // ¾Ï¿¬¼ú.
        SetEffectInfo(&m_stMagicSpr[1],  1900, 1960,  50, _IMAGE_MAGIC,         _SKILL_FIRE, 3, 4,  70,  90, 110,  90, 120, 150);   // ¿°»çÀå.
        SetEffectInfo(&m_stMagicSpr[2],    10,   30,  50, _IMAGE_MAGIC,      _SKILL_TAMMING, 3, 4, 200, 100, 100, 250, 150, 150);   // ·ÚÈ¥°Ý.
        SetEffectInfo(&m_stMagicSpr[3],   140,  159,  50, _IMAGE_MAGIC,   _SKILL_KILLUNDEAD, 3, 4, 200, 100, 100, 100,  75,  50);   // »çÀÚÀ±È¸.
        SetEffectInfo(&m_stMagicSpr[4],   420,  425,  20, _IMAGE_MAGIC,     _SKILL_FIREBALL, 2, 3, 100, 150, 200, 150, 200, 250);   // È­¿°Àå.
        SetEffectInfo(&m_stMagicSpr[5],   610,  620, 100, _IMAGE_MAGIC,     _SKILL_HEALLING, 3, 4, 200, 140, 170, 230, 170, 200);   // È¸º¹¼ú.
        SetEffectInfo(&m_stMagicSpr[6],   640,  650, 100, _IMAGE_MAGIC,   _SKILL_HOLYSHIELD, 3, 4, 120,  60,  60, 150,  80,  80);   // °á°è.
        SetEffectInfo(&m_stMagicSpr[7],   670,  680,  50, _IMAGE_MAGIC,  _SKILL_BIGHEALLING, 4, 5, 200, 140, 170, 230, 170, 200);//200, 100, 100, 250, 150, 150);   // ´ëÈ¸º¹.
        SetEffectInfo(&m_stMagicSpr[8],  2050, 2056,  80, _IMAGE_MAGIC, _SKILL_SHOOTLIGHTEN, 2, 3, 150, 100, 100, 200, 150, 150);   // ·ÚÀÎÀå.
        SetEffectInfo(&m_stMagicSpr[9],   750,  760, 155, _IMAGE_MAGIC,    _SKILL_SKELLETON, 3, 4, 150, 150, 150, 200, 150, 180);   // ¹é°ñ¼ÒÈ¯¼ú.
        SetEffectInfo(&m_stMagicSpr[10],  780,  800, 100, _IMAGE_MAGIC,     _SKILL_SNOWWIND, 5, 6, 255, 123,   0, 255, 123,   0, 255, 255, 255, Blend.LightInv, 0, 1); // ºù¼³Ç³.
        //  SetEffectInfo(&m_stMagicSpr[10],  780,  800, 100, _IMAGE_MAGIC,     _SKILL_SNOWWIND, 4, 5, 220, 150, 150, 250, 170, 170);   // ºù¼³Ç³.
        SetEffectInfo(&m_stMagicSpr[11],  840,  850, 100, _IMAGE_MAGIC,       _SKILL_SHIELD, 3, 4, 100, 100, 100, 100, 140, 180);   // ÁÖ¼úÀÇ¸·.
        SetEffectInfo(&m_stMagicSpr[12],  890,  900, 100, _IMAGE_MAGIC,       _SKILL_SHOWHP, 3, 4,  75,  75,  75, 100,  75,  50);   // Å½±âÆÄ¿¬.
        SetEffectInfo(&m_stMagicSpr[13],  920,  930, 120, _IMAGE_MAGIC,    _SKILL_EARTHFIRE, 4, 5,  40,  60,  80,  60,  80, 100);   // Áö¿°¼ú.
        SetEffectInfo(&m_stMagicSpr[14],  980,  983, 100, _IMAGE_MAGIC,    _SKILL_FIRECHARM, 2, 3, 100, 150, 200, 150, 200, 250, 255, 255, 255, Blend.Normal, 255);    // Æø»ì°è.
        SetEffectInfo(&m_stMagicSpr[15],  980,  983, 100, _IMAGE_MAGIC, _SKILL_HANGMAJINBUB, 2, 3, 150, 100,  50, 200, 150, 100, 255, 255, 255, Blend.Normal, 255);    // Ç×¸¶Áø¹ý.
        SetEffectInfo(&m_stMagicSpr[16],  980,  983, 100, _IMAGE_MAGIC,    _SKILL_DEJIWONHO, 2, 3, 150, 180, 200, 180, 200, 220, 255, 255, 255, Blend.Normal, 255);    // ´ëÁö¿øÈ£.
        SetEffectInfo(&m_stMagicSpr[17],  950,  970, 100, _IMAGE_MAGIC,     _SKILL_FIREBOOM, 5, 6, 100, 150, 200, 150, 200, 250);   // Æø¿­ÆÄ.
        SetEffectInfo(&m_stMagicSpr[18], 1640, 1646,  20, _IMAGE_MAGIC,    _SKILL_FIREBALL2, 2, 3, 100, 150, 200, 150, 200, 250);   // ±Ý°­È­¿°Àå.
        //  SetEffectInfo(&m_stMagicSpr[19], 1450, 1455, 100, _IMAGE_MAGIC,   _SKILL_LIGHTENING, 5, 6, 250, 150, 150, 255, 200, 200);   // °­°Ý.
        SetEffectInfo(&m_stMagicSpr[19], 1450, 1455, 100, _IMAGE_MAGIC,   _SKILL_LIGHTENING, 20, 21, 255, 125, 50, 255, 255, 255);  // °­°Ý.
        SetEffectInfo(&m_stMagicSpr[20],  980,  983, 100, _IMAGE_MAGIC,     _SKILL_BIGCLOAK, 2, 3, 150, 150, 150, 200, 150, 180);   // ´ëÀº½Å.
        SetEffectInfo(&m_stMagicSpr[21],  110,  129,  60, _IMAGE_MAGIC,   _SKILL_SPACEMOVE2, 3, 4, 100, 100, 100, 100, 100, 100);   // ¾Æ°øÇà¹ý2.
        SetEffectInfo(&m_stMagicSpr[22],  110,  129, 100, _IMAGE_MAGIC,   _SKILL_SPACEMOVE3, 3, 4, 100, 100, 100, 100, 100, 100);   // ¾Æ°øÇà¹ý3.

        //~~~ Monster Magic Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetEffectInfo(&m_stMagicSpr[23],    0,    4, 100, _IMAGE_MONMAGIC,    _MONMAGIC_KEPAL, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[24],  300,  320, 100, _IMAGE_MONMAGIC,  _MONMAGIC_EXPLODE, 2, 3, 100, 100,  50, 150, 150,  75); 
        SetEffectInfo(&m_stMagicSpr[25],   20,   30, 100, _IMAGE_MONMAGIC,   _MONMAGIC_BLACK1, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[26],   40,   50, 100, _IMAGE_MONMAGIC,   _MONMAGIC_BLACK2, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[27],   80,   86, 100, _IMAGE_MONMAGIC,  _MONMAGIC_ANTHEAL, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[28],  200,  208, 100, _IMAGE_MONMAGIC, _MONMAGIC_GREATANT, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[29],  280,  289, 100, _IMAGE_MONMAGIC,     _MONMAGIC_RED1, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[30],   40,   50, 100, _IMAGE_MONMAGIC,     _MONMAGIC_RED2, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[31],  220,  227, 100, _IMAGE_MONMAGIC,      _MONMAGIC_ANT, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[32],  240,  246, 100, _IMAGE_MONMAGIC,  _MONMAGIC_WORKANT, 2, 3, 100, 100, 100, 150, 150, 150); 
        SetEffectInfo(&m_stMagicSpr[33],  440,  446, 100, _IMAGE_MONMAGIC, _MONMAGIC_COWGHOST, 2, 3, 100, 100, 100, 150, 150, 150); // ¿ì¸é±Í¿Õ.
        SetEffectInfo(&m_stMagicSpr[34],  980,  986, 100, _IMAGE_MONMAGIC,    _MONMAGIC_SINSU, 2, 3, 100, 100, 100, 150, 150, 150); // ½Å¼ö.
        SetEffectInfo(&m_stMagicSpr[35],  600,  606, 100, _IMAGE_MONMAGIC,   _MONMAGIC_ZOMBIE, 2, 3, 100, 100, 100, 150, 150, 150); // Á»ºñ.
        SetEffectInfo(&m_stMagicSpr[36],  720,  728, 100, _IMAGE_MONMAGIC, _MONMAGIC_JUMAWANG, 2, 3, 100, 100, 100, 150, 150, 150); // ÁÖ¸¶¿Õ.

        SetEffectInfo(&m_stMagicSpr[37], 1240, 1241, 100, _IMAGE_MONMAGIC,         _MONMAGIC_CHIM, 2, 3, 100, 100, 100, 150, 150, 150, 255, 255, 255, Blend.Normal, 255);  // ´ÙÅ©Ä§.
        SetEffectInfo(&m_stMagicSpr[38], 1400, 1401, 100, _IMAGE_MONMAGIC,        _MONMAGIC_ARROW, 2, 3, 100, 100, 100, 150, 150, 150, 255, 255, 255, Blend.Normal, 255);  // ±Ã¼ö°æºñÈ­»ì.
        SetEffectInfo(&m_stMagicSpr[39], 1070, 1071, 100, _IMAGE_MONMAGIC,      _MONMAGIC_MAARROW, 2, 3, 100, 100, 100, 150, 150, 150, 255, 255, 255, Blend.Normal, 255);  // ¸¶±Ã»çÈ­»ì.
        SetEffectInfo(&m_stMagicSpr[40],  800,  806, 100, _IMAGE_MONMAGIC,      _MONMAGIC_DUALAXE, 2, 3, 100, 100, 100, 150, 150, 150, 255, 255, 255, Blend.Normal, 255);  // ½Öµµ³¢ÇØ°ñ´øÁö±â.
        SetEffectInfo(&m_stMagicSpr[41],  520,  527, 100, _IMAGE_MONMAGIC,     _MONMAGIC_COWFLAME, 2, 3, 100, 100, 100, 150, 150, 150); // È­¿°¿ì¸é±Í.
        SetEffectInfo(&m_stMagicSpr[42],  360,  370, 100, _IMAGE_MONMAGIC,  _MONMAGIC_BIGGINE_ATT, 2, 3, 100, 100, 100, 150, 150, 150); // ÃË·æ½Å °ø°Ý.
        SetEffectInfo(&m_stMagicSpr[43],  380,  400, 100, _IMAGE_MONMAGIC, _MONMAGIC_BIGGINE_CHAR, 2, 3, 100, 100, 100, 150, 150, 150); // ÃË·æ½Å¿¡ °ø°Ý´çÇÔ.
        SetEffectInfo(&m_stMagicSpr[44],  320,  330,  70, _IMAGE_MONMAGIC,     _MONMAGIC_SANDFISH, 2, 3, 100, 100, 100, 150, 150, 150,  10,  10,  10, Blend.LightInv, 0);      // »ç¾î°ø°Ý.
        SetEffectInfo(&m_stMagicSpr[45],  260,  266, 100, _IMAGE_MONMAGIC,       _MONMAGIC_BAODIE, 2, 3, 100, 100, 100, 150, 150, 150); // ¹Ùº¸´ÞµåÁ×À½.
        SetEffectInfo(&m_stMagicSpr[46],  880,  886, 150, _IMAGE_MONMAGIC,        _MONMAGIC_SSEGI, 2, 3, 100, 100, 100, 150, 150, 150, 255, 255, 255, Blend.LightInv, 15);     // ½û±â³ª¹æÅ¸¾×.
        SetEffectInfo(&m_stMagicSpr[47],   60,   70, 100, _IMAGE_MONMAGIC,    _MONMAGIC_SINGI_DIE, 2, 3, 100, 100, 100, 150, 150, 150); // ¸ó½ºÅÍÁ×±â. °æ°©¿Ê±â»ç, È«ÀÇ, ÈæÀÇ¸¶¹ý»ç. // ¹æÇâ±¸º°Àº ¾ø´Ù.
        SetEffectInfo(&m_stMagicSpr[48],  680,  689, 100, _IMAGE_MONMAGIC,     _MONMAGIC_HUSU_DIE, 2, 3, 100, 100, 100, 150, 150, 150); // Çã¼ö¾ÆºñÁ×±â.
        SetEffectInfo(&m_stMagicSpr[49],  700,  708, 100, _IMAGE_MONMAGIC,   _MONMAGIC_ZOMBIE_DIE, 2, 3, 100, 100, 100, 150, 150, 150); // Á»ºñÁ×±â.

        SetEffectInfo(&m_stMagicSpr[50],  980,  983, 10, _IMAGE_MAGIC,  _SKILL_SINSU, 3, 4, 150, 150, 150, 200, 150, 180, 255, 255, 255, Blend.Normal, 255);   // ½Å¼ö.

        SetEffectInfo(&m_stMagicSpr[51],  1770,  1790, 100, _IMAGE_MONMAGIC,  _MONMAGIC_EXPLODE1, 2, 3, 100, 100,  50, 150, 150,  75);  

        //~~~ Explosion Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetEffectInfo(&m_stExplosionSpr[0],  200,  220,  80, _IMAGE_MAGIC, _SKILL_HANGMAJINBUB, 4, 5, 200, 150,  60, 255, 170, 100, 255, 255, 255, Blend.LightInv, 0, 1);// Ç×¸¶Áø¹ý.
        SetEffectInfo(&m_stExplosionSpr[1],  170,  190,  80, _IMAGE_MAGIC,    _SKILL_DEJIWONHO, 4, 5, 120, 170, 220, 160, 210, 255, 255, 255, 255, Blend.LightInv, 0, 1);// ´ëÁö¿øÈ£.
        SetEffectInfo(&m_stExplosionSpr[2],  580,  590, 100, _IMAGE_MAGIC,     _SKILL_FIREBALL, 2, 3, 120, 170, 220, 160, 210, 255);    // È­¿°Àå.
        SetEffectInfo(&m_stExplosionSpr[3], 1140, 1150, 100, _IMAGE_MAGIC,    _SKILL_FIRECHARM, 2, 3, 120, 170, 220, 160, 210, 255);    // Æø»ì°è.
        SetEffectInfo(&m_stExplosionSpr[4], 1800, 1810, 100, _IMAGE_MAGIC,    _SKILL_FIREBALL2, 2, 3, 120, 170, 220, 160, 210, 255);    // ±Ý°­È­¿°Àå.
        SetEffectInfo(&m_stExplosionSpr[5],  820,  830, 100, _IMAGE_MAGIC,     _SKILL_BIGCLOAK, 4, 5, 200, 210, 190, 200, 150, 180);    // ´ëÀº½Å.
        //~~~ Monster Explosion Frame Define. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetEffectInfo(&m_stExplosionSpr[6],  100,  110, 100, _IMAGE_MONMAGIC, _MONMAGIC_ANTHEAL, 2, 3, 100, 100, 100, 150, 150, 150);   // ¹æÇâ±¸º°Àº ¾ø´Ù.

        SetEffectInfo(&m_stExplosionSpr[7], 2360, 2379, 100, _IMAGE_MAGIC,  _SKILL_SINSU, 3, 4, 150, 150, 150, 200, 150, 180, 255, 255, 255, Blend.Normal, 255);   // ½Å¼ö.
    }

    public void SetSprDfn(PSpriteFrameInfo frame, ushort first, ushort count, ushort delay)
    {
        frame.FirstFrame = first;
        frame.FrameCount = count;
        frame.FrameDelay = delay;
    }

    public void SetEffectInfo(PSpriteEffectInfo pstEffect, uint dwFstFrm, uint dwEndFrm, ushort wDelay, ushort wImgIdx, ushort wEffectIdx,
                       ubyte bSLightRadius, ubyte bLLightRadius, 
                       ubyte bSLightRColor, ubyte bSLightGColor, ubyte bSLightBColor,
                       ubyte bLLightRColor, ubyte bLLightGColor, ubyte bLLightBColor, 
                       ubyte bMagicRColor = 255, ubyte bMagicGColor = 255, ubyte bMagicBColor = 255, 
                       ubyte bBlendType = Blend.LightInv, ubyte bOpa = 0, ubyte bSwingCnt = 0)
    {
        pstEffect.dwFstFrm = dwFstFrm;
        pstEffect.dwEndFrm = dwEndFrm;
        pstEffect.wDelay   = wDelay;
        pstEffect.wImgIdx  = wImgIdx;
        pstEffect.wEffectIdx = wEffectIdx;

        pstEffect.bLightRadius[0] = bSLightRadius;
        pstEffect.bLightRadius[1] = bLLightRadius;

        pstEffect.bLightColor[0][0] = bSLightRColor;
        pstEffect.bLightColor[0][1] = bSLightGColor;
        pstEffect.bLightColor[0][2] = bSLightBColor;

        pstEffect.bLightColor[1][0] = bLLightRColor;
        pstEffect.bLightColor[1][1] = bLLightGColor;
        pstEffect.bLightColor[1][2] = bLLightBColor;

        pstEffect.bMagicColor[0] = bMagicRColor;
        pstEffect.bMagicColor[1] = bMagicGColor;
        pstEffect.bMagicColor[2] = bMagicBColor;

        pstEffect.bBlendType   = bBlendType;
        pstEffect.bOpa         = bOpa;
        pstEffect.bSwingCnt    = bSwingCnt;
    }

    public PSpriteEffectInfo GetEffectInfo(int effectNo)
    {
        PSpriteEffectInfo pstEffect = null;

        for ( int nCnt = 0; nCnt < _MAX_EFFECT; nCnt++ )
        {
            if ( effectNo == m_stEffectSpr[nCnt].wEffectIdx )
            {
                pstEffect = &m_stEffectSpr[nCnt];           
                break;
            }
        }

        return pstEffect;
    }
    
    public PSpriteEffectInfo GetExplosionInfo(ushort wEffectNum)
    {
        PSpriteEffectInfo pstEffect = null;

        for ( int nCnt = 0; nCnt < _MAX_EXPLOSION; nCnt++ )
        {
            if ( wEffectNum == m_stExplosionSpr[nCnt].wEffectIdx )
            {
                pstEffect = &m_stExplosionSpr[nCnt];
                break;
            }
        }

        return pstEffect;
    }
    
    public PSpriteEffectInfo GetMagicInfo(ushort wEffectNum)
    {
        PSpriteEffectInfo pstEffect = null;

        for ( int nCnt = 0; nCnt < _MAX_MAGIC; nCnt++ )
        {
            if ( wEffectNum == m_stMagicSpr[nCnt].wEffectIdx )
            {
                pstEffect = &m_stMagicSpr[nCnt];        
                break;
            }
        }

        return pstEffect;
    }

    public void SetMonFrameInfo(ushort wMonNum)
    {
        /*  //~~~ Monster ½ºÇÁ¶óÀÌÆ® ¼³Á¤. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        SetSprDfn(&m_stMonSpr[0],    0,  4, 300);           // À¯ÈÞµ¿ÀÛ.
        SetSprDfn(&m_stMonSpr[1],   80,  6, 130);           // °È±âµ¿ÀÛ.
        SetSprDfn(&m_stMonSpr[2],  160,  6, 120);           // ÀÏ¹Ý°ø°Ýµ¿ÀÛ1.
        SetSprDfn(&m_stMonSpr[3],  240,  2, 300);           // ¸Â±âµ¿ÀÛ.
        SetSprDfn(&m_stMonSpr[4],  320, 10, 150);           // Á×±âµ¿ÀÛ.
        SetSprDfn(&m_stMonSpr[5],  400,  6, 150);           // ÀÏ¹Ý°ø°Ýµ¿ÀÛ2.
        SetSprDfn(&m_stMonSpr[6],  480, 10, 150);           // ¸¶¹ý°ø°Ýµ¿ÀÛ1.
        SetSprDfn(&m_stMonSpr[7],  560, 10, 150);           // ¸¶¹ý°ø°Ýµ¿ÀÛ2.
        SetSprDfn(&m_stMonSpr[8],  640,  6, 150);           // ³ªÅ¸³ª±â, »ç¶óÁö±â.
        SetSprDfn(&m_stMonSpr[9],  720,  6, 150);           // Æ¯¼öµ¿ÀÛ1.
        */
        
        // 0. Monster Mtn -> À¯ÈÞµ¿ÀÛ.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[0],    0,  4, 300);
            break;
        default:
            SetSprDfn(&m_stMonSpr[0],    0,  4, 300);       
            break;
        }

        // 1. Monster Mtn -> °È±âµ¿ÀÛ.
        SetSprDfn(&m_stMonSpr[1],    80,  6, 90);

        // 2. Monster Mtn -> ÀÏ¹Ý°ø°Ýµ¿ÀÛ1.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case 12: case 99:    
            SetSprDfn(&m_stMonSpr[2],  160,  6, 120);   // ÀúÆÄ, ¾ßÇà±Í, ÄÉÆÈ·ÎÇÁ, °ß, ¹Ù¿À´Þµå.
            break;
        case 14: case 16: case 92:
            SetSprDfn(&m_stMonSpr[2],  160,  6, 140);   // º´¿ë°³¹Ì, µå³­°³¹Ì, ´Ù°ï.
            break;
        case  3: case  5: case  6: case  7: case  8: case  9: case 15: case 19: case 93: case 96: case 97: case 98:
            SetSprDfn(&m_stMonSpr[2],  160,  6, 150);   // »ç±«, ¹ÙÄí°¡¸£³ª, ¹ÙÀÚ¿ï, Ä¡À¯°³¹Ì, °©ÁÖ°³¹Ì, ·Ð, ´©¸¶¿Õ, ·¹µð°¡¸£³ª, µ¥³ª°¡´ÙÄÚ, Æ÷·ç°³¹Ì, Ç³¹é, ´©¸¶¿Õ1.
            break;
        case  4: case 10: case 11: case 13: case 17: case 18: case 94:
            SetSprDfn(&m_stMonSpr[2],  160,  6, 170);   // ¼®ÀåÀÎ, ¸ðµðÁ¯, ¸ðµðÁ¯1, ´©¸¶¹ý·Î, ´©¸¶ºñÀå, ´©¸¶, »ç¾î.
            break;
        default:
            SetSprDfn(&m_stMonSpr[2],  160,  6, 130);   
            break;
        }

        // 3. Monster Mtn -> ¸Â±âµ¿ÀÛ.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[3],  240,  2, 300);   
            break;
        case  116:                                      // ¸».
        case  117:                                      
        case  118:                                      
            SetSprDfn(&m_stMonSpr[3],  240, 3, 160);        
            break;
        default:
            SetSprDfn(&m_stMonSpr[3],  240,  2, 300);   
            break;
        }

        // 4. Monster Mtn -> Á×±âµ¿ÀÛ.
        switch ( wMonNum )
        {
        case  94:                                       // »ç¾î
            SetSprDfn(&m_stMonSpr[4],  320, 10, 160);       
            break;
        case  30:                                       // ¹¶ÄÚ.
            SetSprDfn(&m_stMonSpr[4],  320, 4, 160);        
            break;
        case  104:                                      // Àû¿ù¸¶.
            SetSprDfn(&m_stMonSpr[4],  320, 20, 160);       
            break;
        default:
            SetSprDfn(&m_stMonSpr[4],  320, 10, 165);
            break;
        }

        // 5. Monster Mtn -> ÀÏ¹Ý°ø°Ýµ¿ÀÛ2.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[5],  400,  6, 150);
            break;
        default:
            SetSprDfn(&m_stMonSpr[5],  400,  6, 150);       
            break;
        }

        // 6. Monster Mtn -> ¸¶¹ý°ø°Ýµ¿ÀÛ1.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[6],  480, 10, 150);       
            break;
        default:
            SetSprDfn(&m_stMonSpr[6],  480, 10, 150);       
            break;
        }

        // 7. Monster Mtn -> ¸¶¹ý°ø°Ýµ¿ÀÛ2.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[7],  560, 10, 150);       
            break;
        default:
            SetSprDfn(&m_stMonSpr[7],  560, 10, 150);       
            break;
        }

        // 8. Monster Mtn -> »ç¶óÁö±â, ³ªÅ¸³ª±â µ¿ÀÛ.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[8],  640,  10, 150);      
            break;
        case 83:    // ÁÖ¸¶½ÅÀå.
            SetSprDfn(&m_stMonSpr[8],  640,  6, 150);       
            break;
        case 84:    // ÁÖ¸¶È£¹ý.
            SetSprDfn(&m_stMonSpr[8],  640,  6, 150);       
            break;
        case 85:    // ÁÖ¸¶¿Õ.
            SetSprDfn(&m_stMonSpr[8],  640,  20, 150);      
            break;
        default:
            SetSprDfn(&m_stMonSpr[8],  640,  10, 150);      
            break;
        }

        // 9. Monster Mtn -> Æ¯¼öµ¿ÀÛ1.
        switch ( wMonNum )
        {
        case  0: case  1: case  2: case  3: case  4: case  5: case  6: case  7: case  8: case  9:
            SetSprDfn(&m_stMonSpr[9],  720,  6, 150);       
            break;
        default:
            SetSprDfn(&m_stMonSpr[9],  720,  6, 150);       
            break;
        }
    }

    public bool SetWeaponOrder(string flname)
    {
        if (std.file.exists(flname) == true)
        {
            File wreader = new File;
            scope(exit) { destroy(wreader); }
            wreader.open(flname, FileMode.In);
            if ( wreader.isOpen() )
            {
                wreader.readBlock(&m_bWOrder[0], _MAX_HERO_REALFRAME);
                wreader.close();
                
                return true;
            }
        }
        
        return false;
    }
}